<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<div class="edit-tools">
<?php 
if(is_object($adc->CurrentAd))
{
	if(($user->getId() == $adc->CurrentAd->getUserId()) || ($user->getLevel() > 4))
	{
		unset($buttons);
		$statusTxt = '';
		
		$buttons[0]['title'] = ucfirst($txt->getWord('my_ads'));
		$buttons[0]['href'] = '/c/11/?list=ad';
		$buttons[0]['params']['class'] = 'bold btn btn-default';
		
		$buttons[1]['title'] = ucfirst($txt->getWord('edit').' '.$txt->getWord('this_ad'));
		$buttons[1]['href'] = '/c/11/?edit=ad&ad='.$adc->CurrentAd->getId();
		$buttons[1]['params']['class'] = 'bold btn btn-default';
		
		if($adc->getCurrentAd()->getIsCompleted() > 0)
		{
			if(($adc->getCurrentAd()->getIsPaid() > 0) && ($adc->getCurrentAd()->getIsValid()))
			{ 
				$buttons[2]['title'] = ucfirst($txt->getWord('publish').' '.$txt->getWord('again'));
				$buttons[2]['href'] = '/c/11/?list=ad&activate='.$adc->getCurrentAd()->getId().'';
				$buttons[2]['onclick'] = '';
				$buttons[2]['params']['class'] = 'bold btn btn-success';
				$statusTxt = ucfirst($adc->getCurrentAd()->getIsBoughtText());
				
				$buttons[3]['title'] = ucfirst($txt->getWord('archive'));
				$buttons[3]['href'] = '/c/11/?list=ad&archive='.$adc->getCurrentAd()->getId().'';
				$buttons[3]['onclick'] = '';
				$buttons[3]['params']['class'] = 'bold btn btn-warning';
			}
		}
		else
		{
			if($adc->getCurrentAd()->getActive() > 0)
			{ 
				$buttons[2]['title'] = ucfirst($txt->getWord('set_as').' '.$adc->getCurrentAd()->getIsBoughtText());
				$buttons[2]['href'] = '/c/11/?list=ad&complete='.$adc->getCurrentAd()->getId().'';
				$buttons[2]['onclick'] = '';
				$buttons[2]['params']['class'] = 'bold btn btn-success';
				$statusTxt = ucfirst($txt->getWord('published'));
			}
			else
			{ 
				if($adc->getCurrentAd()->getIsPaid() > 0)
				{
					if($adc->getCurrentAd()->getIsValid())
					{
						$buttons[2]['title'] = ucfirst($txt->getWord('publish'));
						$buttons[2]['href'] = '/c/11/?list=ad&activate='.$adc->getCurrentAd()->getId().'';
						$buttons[2]['onclick'] = '';
						$buttons[2]['params']['class'] = 'bold btn btn-success';
						$statusTxt = ucfirst($txt->getWord('paid'));
					}
				}
				else
				{ 
					if($adc->getCurrentAd()->getIsValid())
					{
						$buttons[2]['title'] = ucfirst($txt->getWord('proceed_to_payement')).' >>';
						$buttons[2]['href'] = '/c/11/?edit=payment&ad='.$adc->getCurrentAd()->getId().'';
						$buttons[2]['onclick'] = '';
						$buttons[2]['params']['class'] = 'bold btn btn-success';
						$statusTxt = ucfirst($txt->getWord('not').' '.$txt->getWord('paid'));
					}
				}
			}
		}
		if(($user->getLevel() > 4) || ($adc->getCurrentAd()->getIsDeletable() > 0))
		{
			$buttons[4]['title'] = ucfirst($txt->getWord('delete'));
			if($user->getLevel() > 4)
			{ $buttons[4]['href'] = '/ad/'.$adc->getCurrentAd()->getId().'/?Delete=1'; }
			if($user->getId() == $adc->CurrentAd->getUserId())
			{ $buttons[4]['href'] = '/c/11/?list=ad&delete='.$adc->getCurrentAd()->getId().''; }
			$buttons[4]['onclick'] = '';
			$buttons[4]['params']['class'] = 'bold btn btn-danger';
		}
		if($user->getLevel() > 4)
		{
			$buttons[5]['title'] = ucfirst($txt->getWord('ad_gallery_display'));
			if($adc->getCurrentAd()->getGalleryDisplay() > 0)
			{ 
				$buttons[5]['title'] = ucfirst($txt->getWord('ad_gallery_display').' '.$txt->getWord('active'));
				$buttons[5]['href'] = '#';
				$buttons[5]['params']['class'] = 'bold btn btn-success disabled'; 
			}
			else
			{ 
				$buttons[5]['href'] = '/ad/'.$adc->getCurrentAd()->getId().'/?GalleryDisplay=1';
				$buttons[5]['params']['class'] = 'bold btn btn-warning'; 
			}
		}
		
		echo '<div class="command-bar">';
		echo getButtonsHTML($theme->HFBSets[$theme->ComHFB]['button'], $buttons);
		?></div><div class="clear"></div><hr />
        <p>
		<?php echo ucfirst($txt->getWord('current').' '.$txt->getWord('status')).': <b>'.$statusTxt.'</b>&nbsp;&nbsp;|&nbsp;&nbsp;'; ?>
        <?php echo ucfirst($txt->getWord('detail_views')).': <b>('.$adc->CurrentAd->getViewsDetail().')</b> '.'&nbsp;&nbsp;|&nbsp;&nbsp;'; ?>
        <?php echo ucfirst($txt->getWord('list_views')).': <b>('.$adc->CurrentAd->getViewsList().')</b>'; ?> 
        </p>
        <?php
	}
	else
	{
		if($user->getId() != $adc->CurrentAd->getUserId())
		{
			if($user->getId() > 0)
			{
				if($_POST['action'] == 'addBookmark')
				{ $adc->addBookmark(); }
				
				if(is_object($adc->getCurrentAdBookmark()))
				{
					?>
                    <div class="sold float-left">
                    	<p class="float-left">Annonsen lagret i <a href="/c/11/?list=bookmark">mine funn</a>.&nbsp;&nbsp;</p>
                        <img width="24" height="24" src="<?php echo SITE_URL; ?>images/icons/crystal/ok_24.png" alt="Lagret">
                     </div><div class="clear"></div>
                    <?php
				}
				else
				{
					unset($buttons);
					$buttons[0]['title']   = ucfirst($txt->getWord('add_to_my_favorites'));
					$buttons[0]['onclick'] = 'jQuery(\'form#AdBookmark\').submit();';
					$buttons[0]['params']['class'] = 'btn btn-default';
					$buttons[0]['params']['icon']  = 'icon-heart';
					
					$buttons[1]['title']   = ucfirst($txt->getWord('share_on_facebook'));
					$buttons[1]['href'] = 'http://www.facebook.com/sharer.php?u='.SITE_URL.'ad/'.$adc->CurrentAd->getId();
					$buttons[1]['params']['target'] = '_blank';
					$buttons[1]['params']['class'] = 'btn btn-default';
					
					$buttons[2]['title']   = ucfirst($txt->getWord('print'));
					$buttons[2]['href'] = '?print=1';
					$buttons[2]['params']['target'] = '_blank';
					$buttons[2]['params']['class'] = 'btn btn-default';
					
					echo getButtonsHTML($theme->HFBSets[$theme->ComHFB]['button'], $buttons);
					
					?>
					<form name="addBookmark" id="AdBookmark" method="post" action="">
						<input type="hidden" name="action" value="addBookmark" />
					</form>
					<?php
				}
			}
			else
			{
				unset($buttons);
				$buttons[0]['title']   = ucfirst($txt->getWord('add_to_my_favorites'));
				$buttons[0]['onclick'] = 'jQuery(\'#loginLink\').show(\'blind\');';
				$buttons[0]['params']['class'] = 'btn btn-default';
				$buttons[0]['params']['icon']  = 'icon-heart';
				
				$buttons[1]['title']   = ucfirst($txt->getWord('share_on_facebook'));
				$buttons[1]['href'] = 'http://www.facebook.com/sharer.php?u='.SITE_URL.'ad/'.$adc->CurrentAd->getId();
				$buttons[1]['params']['target'] = '_blank';
				$buttons[1]['params']['class'] = 'btn btn-default';
				$buttons[1]['params']['icon']  = 'icon-facebook-sign';
				
				$buttons[2]['title']   = ucfirst($txt->getWord('print'));
				$buttons[2]['href'] = '?print=1';
				$buttons[2]['params']['target'] = '_blank';
				$buttons[2]['params']['class'] = 'btn btn-default';
				$buttons[2]['params']['icon']  = 'icon-print';
				
				echo getButtonsHTML($theme->HFBSets[$theme->ComHFB]['button'], $buttons);
				?>
				<div class="clear"></div>
				<div id="loginLink" <?php if ($_POST['action'] != 'login_user') ?> style="display:none;">
                	<hr />
                	<p class="float-left"><?php echo ucfirst($txt->getWord('you_must_be_logged_inn').' '.$txt->getWord('to_preform_this_action')); ?>.</p><div class="clear"></div>
                    <div>
                    	<h3 class="section-title"><?php echo ucfirst($txt->getWord('login')); ?></h3>
                        <form id="<?php echo $com->Id; ?>_login_user" action="" method="post" enctype="multipart/form-data" name="login_user">
                            <fieldset class="com_form">
                                <?php echo $ac->getForms('login')->getFieldsHTML(); ?><br />
                            </fieldset>
                        </form><br /><a href="/c/11/" class="bold"><?php echo ucfirst($txt->getWord('new_user')); ?> &gt;&gt;</a>
                    </div>
                </div><div class="clear"></div>
				<?php
			}
		}
	}
}
?>
</div><div class="clear"></div><hr />